package anthology.daily_question._25_01;

import java.util.Arrays;

//https://leetcode.cn/problems/maximum-number-of-coins-you-can-get/description/?envType=daily-question&envId=2025-01-22
public class _1561你可以获得的最大硬币数目 {
    class Solution {
        public int maxCoins(int[] piles) {
            Arrays.sort(piles);
            int length = piles.length;
            int rounds = length / 3;
            int coins = 0;
            int index = length - 2;
            for (int i = 0; i < rounds; i++) {
                coins += piles[index];
                index -= 2;
            }
            return coins;
        }
    }
}
